import Vue from 'vue'
import VueRouter from 'vue-router'

// 注册VueRouter提供的组件
Vue.use(VueRouter)
// 路由规则而数组（路由表）
const routes = [

  {
    path: '/login',
    component: () => import('@/views/login')
  },
  {
    path: '/',
    component: () => import('@/views/layout'),
    children: [
      {
        path: '',
        component: () => import('@/views/home')
      },
      {
        path: '/qa',
        component: () => import('@/views/qa')
      },
      {
        path: '/video',
        component: () => import('@/views/video')
      },
      {
        path: '/my',
        component: () => import('@/views/my')
      }
    ]

  },
  {
    path: '/search',
    component: () => import('@/views/search')
  },
  {
    path: '/article/:articleId', // 动态路由
    name: 'article',
    component: () => import('@/views/article'),
    // 将路由动态参数映射到组件的 props 中，更推荐这种做法
    props: true
  },
  {
    path: '/user/profile',
    component: () => import('@/views/user-profile/index.vue')
  }

]

const router = new VueRouter({
  routes// 注册路由规则
})

export default router
